package com.program.wechatmall.service.Impl.userManagement;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.program.wechatmall.bean.userManagement.Admin;
import com.program.wechatmall.bean.userManagement.User;
import com.program.wechatmall.bean.userManagement.UserManagementVO;
import com.program.wechatmall.mapper.userManagement.AdminMapper;
import com.program.wechatmall.service.userManagement.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: chengxin
 * @Date :  2020/8/31 19:58
 * @Version 1.0
 */
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;


    @Override
    public Admin queryAdminById(Integer id) {
        Admin admin = adminMapper.queryAdminById(id);
        return admin;
    }

    @Override
    public UserManagementVO queryAllUsersInfo(Integer page, Integer limit, String addTime, String order) {
        //开启分页
        PageHelper.startPage(page, limit);
        List<User> users = adminMapper.queryAllUsersInfo(addTime, order);
        PageInfo<User> pageInfo = new PageInfo<>(users);
        long total = pageInfo.getTotal();
        UserManagementVO userManagementVO = new UserManagementVO();
        userManagementVO.setItems(users);
        userManagementVO.setTotal(total);
        return userManagementVO;
    }


}
